
package ma.ensias.healthme.admin;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import ma.ensias.healthme.R;
import ma.ensias.healthme.dao.PointTraitDao;
import ma.ensias.healthme.entities.Maladie;
import ma.ensias.healthme.entities.PointTrait;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class ListPTActivity extends Activity {


	ListView list;
    PTLazyAdapter adapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list_pt);
		

		final List<PointTrait> pts ;
		
		PointTraitDao ptDao=new PointTraitDao();
		
		pts=ptDao.getPointTraits();
		
		System.out.println(pts.size());
		
		
		list=(ListView)findViewById(R.id.listPT);
		
        adapter=new PTLazyAdapter(this,(ArrayList<PointTrait>)pts);        
        list.setAdapter(adapter);
        
       

        // Click event for single list row
        list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				
			    PointTrait p=pts.get(position);
			    showMs(p);
			}
		});	 
	}
	
	
	public void showMs(PointTrait p){
		Intent i=new Intent(this,ListMaladieActivity.class);
		i.putExtra("p", (Serializable)p);
		startActivity(i);
	}

	
	
	
}
